Tumgik
#testcase
doodles-and-stuff53 · 27 days
Text
Tumblr media
Don't reblog this. Take a screenshot and tag your OTPS
1 note · View note
news4u95 · 1 year
Link
0 notes
t4sqa · 2 years
Text
Artifacts of Testing
Tumblr media
- Bug report A defect (also known as a bug) is a discrepancy between the actual result of the program execution and the expected result. Defects are discovered at the stage of software (software) testing, when the tester compares the results of the program (component or design) with the expected result described in the requirements specification. So, as soon as we discover a bug, we need to document it in order to continue the life cycle of the defect (which we considered earlier). A document that describes a bug is called a bug report. A bug report is a technical document that contains a complete description of a bug, including information about both the bug itself (short description, severity, priority, etc.) and the conditions under which the bug occurred. The bug report should contain correct, unified terminology that describes the user interface elements and the events of these elements that lead to the bug. In general, a bug report consists of: Hat. - Short description (short description of the problem).  - Project (name of the current project).  - Application component (in which the defect occurred).  - Version (version of the build in which the bug was found).  - Severity (gradation of the degree of impact on the application of the bug).  - Priority (bug fix queue).  - Status (displays the status of the bug in its lifecycle).  - Author (author of the bug report).  - Assignment (who should fix the defect). Environment.  - Operating system, bit depth, Service Pack, browser, version, etc.  Description.  - Reproduction steps (description of the path that leads to the occurrence of the defect).  - The actual result (the result we arrive at after completing all the playback steps).  - Expected result (the result that be in accordance with the requirements). Additions.  - Attached file (logs, screenshots, and other documents that may help reproduce the problem or solve it).  Despite such a large number of bug report items, there are several main fields that must be present:  - Short description. The field in which you need to put the whole meaning of the entire bug report. Most often, in a short description, they briefly answer 3 questions: “Where?”, “What?”, “When?”. - Priority. The defect either completely stops the application from working, or only part of the functionality, or otherwise.  - Reproduction Steps. An accurate and understandable description of all the steps that lead to the appearance of a defect, taking into account all the necessary input data, etc.  - Actual result.  - Expected Result. - Test Case Test Case is a test artifact, the essence of which is to perform a certain number of actions and/or conditions necessary to test a certain functionality of the developed software system.  The structure of this artifact is in the "trinity": Action performed – Expected result – Actual result. The test case consists of 3 parts: - PreConditions - either a list of steps that bring the system under test into a state suitable for testing, or a list of checks for conditions that the system is already in the required state.  - Test Case Description - a list of actions by which the main test of the functionality is carried out (after which the actual result is compared with the expected one).  - PostConditions  - a list of actions that return the system to its original state. The way of describing test cases and their structure can be different in each company or team: they have different depths of the description of the necessary actions and results, have different structural components. But, good structure and high usability of test case templates can greatly reduce the time of routine form filling and increase the efficiency of the team as a whole. 3. Checklist Checklist - a set of ideas for testing, development, planning, and management. And also, this is a list of formalized test cases in a form convenient for conducting checks. Test cases in a checklist should not be dependent on each other.  Must contain the following information: - idea of ​​checks;  - a set of input data;  - expected results;  - boolean mark about passing/failing the test case;  - boolean mark about the match/non-match of the actual and expected result for each test. It may also contain the steps for conducting the check, data about the features of the environment, and other information necessary for carrying out the checks. The goal is to ensure that requirements are consistently covered by checks that are necessary and sufficient to conclude that the product conforms to them. The peculiarity is that checklists are composed of those test cases that are indicative of a specific requirement. There are two types of checklists: special and universal.  Special checklists are created and used for specific projects, so the items in such a checklist correspond to the specifics of the project. The tester, using a special checklist, checks the ability to perform a unique action provided for by the requirements.  Universal checklists are suitable for testing projects of the same type. Verification according to the universal checklist is not tied to graphic elements or a specific implementation, but the very ability of the user to perform an action is checked. An abstract list of checks is compiled for the universal checklist. Universal checklists can be reused on projects of the same type. 4. Test Plan Test Plan is a document that describes the entire scope of testing work, starting with a description of the objects being tested, a strategy, schedule, criteria for starting and ending testing, the equipment required in the process, special knowledge, and risk assessment with options for resolving them.  A test plan is an important part of any well-organized testing process, as it contains all the necessary information that describes this process. But in most cases that we will have to deal with, the test plan will play a more formal role, but still, its presence has many advantages. For example: - Ability to prioritize testing tasks.  - Building a testing strategy agreed with the entire team.  - Ability to keep records of all required resources, both technical and human.  - Planning the use of resources for testing.  - Calculation of risks possible during testing.  Depending on the specification of the described tasks, a test plan can have two levels of detail: a master test plan and a detailed test plan. Detailed Test Plan contains test tasks for each team, for each release or iteration of the project. A detailed test plan is created either for the decomposed part of the project or for small projects. It may consist of:  - List of testing areas with priorities.  - Testing strategy.  - List of possible risks.  - List of required resources.  - Project implementation plan. Master Test Plan is created either to organize the testing process between several teams that test one project, but have different tasks, or for a project that consists of many iterations that are connected by some common information, the repetition of which in each release takes too long. The master test plan includes:  - General information about the project (links to documentation, bug trackers, etc.)  - Provisions describing the testing process, the introduction of defects, etc.  - Criteria for product readiness for release. Read the full article
0 notes
mmtinstitutes-blog · 4 months
Text
Gear up for a comprehensive Software Testing course
Exciting news at MMT Institute. 🚀 Gear up for a comprehensive Software Testing course that opens doors to a world of quality assurance. 🕵️‍♂️ Dial 9644004360 to enroll and ensure your spot or explore mmtinstitute.in for details. Unleash your testing expertise and embark on a rewarding career in software quality. Join us to learn the ins and outs of testing methodologies and boost your professional journey. 🖥️
Tumblr media
0 notes
Text
Tumblr media
Are you zealous about building test cases and automation scripts for core applications and new features? Here is a classic opportunity for you to work with us and ensure the defect-free release of the application!
We are looking to hire an experienced Test Lead with prowess in Jira, MF. ALM!
Are you interested? Read the complete job description below and send your resume to us!
https://bizessence.com.au/jobs/test-lead/
0 notes
9-yards-technology · 1 year
Photo
Tumblr media
Effective Tips for Writing Better Test Cases in Software Testing
For more, contact us at (+91-9711311331)
0 notes
webomates · 1 year
Text
Tumblr media
As per Webomates’ study, the cost of software test automation is only 20% in the setup phase, and the cost of maintenance of the software test automation is 80% of the overall cost.
The broken test cases and scripts disrupt the software release cycle, and analyzing the root cause of broken test scripts is even more time-consuming.
AiHealing bridges the gap as it not only identifies the changes in the test cases and automation scripts but also adapts them in real time. AiHealing is playing a vital role in faster software release.
Read more about it at - https://www.webomates.com/blog/aihealing/self-heal-automation-with-aihealing/
Know How Webomates' AiHealing works at https://www.webomates.com/aihealing/
Talk to Us at https://www.webomates.com/schedule-demo/
For Regular Updates: ➤ Facebook: https://www.facebook.com/Webomates/ ➤ LinkedIn: https://www.linkedin.com/company/webomates/ ➤ Twitter: https://lnkd.in/gZqr7VNJ ➤ YouTube: https://www.youtube.com/channel/UCJkGoVwmgQK7rZYdpK_w11g ➤ Instagram: https://www.instagram.com/webomates/
0 notes
katyslemon · 2 years
Text
Implement Feature Testing in Laravel for REST APIs
Introduction
Is working with test cases intimidating for you? Are you looking for a simple tutorial to get started with feature testing in Laravel? Then, we insist you stick to this step-by-step guide to clear your doubts and learn testing in the Laravel application.
Feature Testing in Laravel: What, Why, and How?
What is Feature Testing in Laravel?
When developing an application, you tend to worry about code breakage while executing a feature or modules. To avoid scenarios, it is significant to implement testing in your application.
Feature testing is one of the most used and important types of testing. It allows you to test a major portion of your application’s code that has objects interacting with each other, HTTP requests, JSON, etc.
Why Feature Testing in Laravel?
To make smooth working functionality
Avoid breaking your entire application
Code maintainability
Application stability
Easy debugging when an application crashes
Easy fixating of the reason behind app break-down
The best part is testing is it is automated. It finds the gap in your code and allows you to develop features right.
How Does Feature Testing in Laravel Work?
Laravel supports PHPUnit tests. Your web app comes with a phpunit.xml file with all the settings you need to test your Laravel application. Your phpunit.xml file sets your laravel environment for testing. So there is no need to create a new XML file!
Below is a sample phpunit.xml file that comes with the Laravel 8 framework.
Read more for Testing in Laravel for REST APIs
0 notes
birbs-in-space · 8 months
Text
would it be bad to log out of work like 10 minutes after getting an answer from coworker about how to proceed with my testcase😔
7 notes · View notes
govindhtech · 1 month
Text
Quality assurance using IBM Ignite Quality Platform
Tumblr media
IBM Ignite Platform
QA is a vital phase in the software development lifecycle, verifying that software fulfills quality standards before release. QA is a systematic approach of discovering, preventing, and correcting issues throughout the development process.
But there are a number of issues in the QA field that impact defect volume, test case automation, and test case inventory. The huge number of test cases might make managing the inventory difficult and result in inefficiencies and resource shortages. Test case automation is useful, but it may also present difficulties when it comes to choosing the right instances, ensuring adequate upkeep, and obtaining thorough coverage. Software quality and release schedules are impacted by defect volume, which is a constant source of worry.
To overcome these obstacles, a careful and proactive strategy is needed to reduce the number of errors in the QA process, maximize the efficacy of automation, and simplify test cases. Delivering high-quality software solutions that satisfy user expectations and industry requirements requires striking a balance between these factors.
IBM Ignite testing Test case optimization must be the main priority if test case volume is to be decreased. In order to cover different situations, this method entails finding duplicate or overlapping test cases and unifying them. It’s crucial to prioritize test cases according to crucial features and possible hazards in order to maximize testing efficiency. By maximizing coverage without sacrificing quality, teams may also direct resources where they are most needed by using risk-based testing. Careful design and ongoing maintenance may improve the efficacy of test case automation.
Another approach is to carefully choose the test cases for automation, emphasizing crucial, time-consuming, and repeated circumstances. Automated test scripts must also be updated on a regular basis to ensure their relevance and dependability in the face of application changes. Implementing strong testing approaches, such as shift-left testing, where testing activities are started earlier in the development process, is a proactive response to faults. To find and fix bugs early, development and testing teams should emphasize cooperation, use tools for static analysis, and conduct comprehensive code reviews.
All of this is provided by IBM via The IBM IGNITE Quality Platform (IQP), a DevOps-enabled single sign-on platform that optimizes testing using proprietary techniques and AI capabilities. The platform introduces shift left strategies that support an organization’s end-to-end testing lifecycle by accelerating automation with healing capabilities and predicting and preventing problems. These approaches also lead to high-quality delivery.
IBM Ignite tool Handle: Supported by an integrated platform that centrally and in one location controls several tenants, users, apps, projects, and all the functional and technical settings required for the testing process. It also encourages the quality plan journey, which lowers faults as its goal. Additionally, it incorporates several third-party connectors, including top git-based repositories, test and defect tools, and cloud-based web and mobile testing tools, as well as quality suggestions that come from other components.
Optimize: Aimed to bring in a shift left in revealing faults early and provide the best possible collection of testcases with 100% coverage.
Requirement analytics (RA): A natural language processing (NLP) tool for requirements analysis that drives in shift left, finds ambiguities, and assesses complexity. Additionally, it helps identify important features for the optimization journey in a semi-automated manner.
Search Tag & Model (STAM) Using a text-based analytics tool called Search Tag & Model (STAM), users may quickly analyze a large number of pre-existing tests to find redundancies and pinpoint important characteristics for the optimization process.
Optimization (TO): A tool based on the Combinatorial Test Design Methodology that facilitates the creation of an optimized test plan with the greatest possible coverage using YAML, relational data, existing tests, and current requirements. incorporates ideas of functional context modeling and attribute pooling for reusability.
IBM Ignite test automation The goal was to swiftly create, automate, and run many unattended tests on a range of platforms, data, and settings.
Assists in producing TO model-based and nonmodel-based tests that are prepared for both automated and manual testing (Test Generation, TG). Additionally, it facilitates the rapid conversion of bespoke Selenium-based frameworks to IQP-specific automation, automated BDD script development using recording mechanisms, and custom BDD generation for client-based frameworks. Optimized Test Flow Automation (OTFA) is a scriptless test automation framework based on Cucumber that supports the automation of Web, Mobile, REST, and SOAP-based applications. It integrates Jmeter-based performance testing with visual testing and has an integrated test healing feature.
Analyze Skilled in comprehending the defect patterns of a client, cognitive test components facilitate speedier defect resolution, provide insight, and forecast potential issues. These predictions lead to preventative advice that may be used to both Agile and conventional engagements. Better planning and fewer test cycles are also facilitated by its failure prediction capacity.
Defect Classify (IDC) is a plug-in solution that enables automated defect assignment and categorization while on the move, facilitating quicker defect analysis and resolution. Defect Analytics (IDA): Designed with the defect reduction approach in mind, this tool comprehends the flaws’ semantics and offers preventive advice to further minimize them. In order to improve test management and planning, Defect Predict (IDP) evaluates and forecasts the trend of defects in a test cycle. IBM’s unique methods to automation
IBM is prioritize optimization over automation as part of their multiple shift-left methodology approach to reduce the waste snowball effect. IBM make use of a contemporary framework that integrates low-code techniques and supports behavior-driven development (BDD). IBM methodology encompasses a thorough automation of Web, Mobile, API, and SOAP-based applications, which is smoothly combined with performance testing.
Their approach is to carefully integrate every function into the DevOps pipeline, encouraging a unified and effective development lifecycle, all while adhering to the continuous testing concept. Beyond this, they also support Software as a Service (SaaS) solutions and cloud deployment, promoting scalability, flexibility, and accessibility in a quickly changing technological environment.
Proof of the effectiveness of the IGNITE Quality and Test IBM’s main goal is to provide their customers with measurable value by strategically minimizing testing requirements and while fostering client trust. IBM’s multi-technical experience allows them to provide a full and adaptable solution that fulfills their clients’ needs. IBM consistent results and client trust have reinforced their market leadership and dedication to meaningful solutions.
Read more on Govindhtech.com
0 notes
shalcool15 · 2 months
Text
Pytest vs. Python Unittest: A Comprehensive Comparison of Python Testing Frameworks
Testing is a crucial phase in the software development process, ensuring the delivery of reliable and error-free applications. In the Python ecosystem, Pytest and Unittest are two popular frameworks that facilitate the creation and execution of tests, each with its unique features and advantages. This blog, Pytest vs. Python Unittest, offers a detailed comparison of Pytest and Unittest, exploring their functionalities, practical applications, and what sets them apart.
Introduction to Testing in Python
Before delving into the specifics of Pytest and Unittest, it's essential to understand the role of testing in Python. Testing automates the process of verifying that your code behaves as expected, catching errors and bugs before they reach production. It contributes to higher code quality, more robust applications, and a smoother development process simplifying it for businesses looking to hire python developers.
Understanding Unittest
Unittest, also known as Python’s standard “unittest” framework, is inspired by JUnit. It comes prepackaged with Python, requiring no additional installations to get started. Unittest supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework.
Key Features:
TestCase: The primary building block of Unittest, allowing the creation of individual tests by subclassing it.
Test Fixture: Supports setting up preconditions and cleaning actions for tests.
Test Runner: A component that orchestrates the execution of tests and provides the output to the user.
Test Case: Encapsulates the input, execution, and verification steps of a test.
Practical Applications:
Unittest is ideal for traditional, OOP-based Python projects where tests correspond to modules or classes. It’s widely used in enterprise environments or in projects where a structured, regimented approach to testing is required.
Exploring Pytest
Pytest is a no-boilerplate alternative to Unittest. It simplifies and enhances the testing experience with its more pythonic approach. Pytest can run tests written for Unittest without modification, making it flexible and powerful.
Key Features:
Simple Syntax: Write tests in a concise, readable manner using plain assert statements.
Fixtures: Powerful feature for setup and teardown operations, providing modular and reusable components for tests.
Parametrization: Easily test different inputs with a single test function.
Plugins: Extendable with a wide range of plugins for integration, parallel test execution, and more.
Practical Applications:
Pytest is suitable for a wide range of projects, from simple scripts to complex applications. It’s particularly beneficial for projects that require rapid development cycles, thanks to its ease of writing and reading tests. Pytest shines in scenarios requiring extensive parameterization or when leveraging its rich plugin ecosystem.
Unique Aspects and Differences
While both frameworks serve the primary purpose of testing, several differences make each unique:
Simplicity vs. Convention: Pytest offers a more straightforward approach to writing tests, often requiring fewer lines of code and no boilerplate, compared to the more structured and formal approach of Unittest.
Fixtures vs. Test Fixtures: Pytest fixtures are more flexible and powerful than Unittest’s setup and teardown methods, offering broader functionality with less code.
Parametrization: Pytest’s parametrize decorator allows for more dynamic generation of tests compared to the more manual process in Unittest.
Plugin System: Pytest’s extensive plugin system is a significant advantage, allowing for easy extension and customization of the testing process.
Choosing the Right Framework
The choice between Pytest and Unittest often boils down to personal preference, project requirements, and the specific needs of your testing strategy. If you prefer a more structured approach with the support of Python’s standard library, Unittest might be the way to go. On the other hand, if you value simplicity, flexibility, and the power of plugins, Pytest could be more aligned with your needs as you approach top python development companies for your projects.
Conclusion
Both Pytest and Unittest have their strengths and are capable of supporting a robust testing strategy for Python applications. By understanding the unique aspects and practical applications of each, developers can make an informed choice about which framework best suits their project's needs. Regardless of the choice, embracing testing is a step towards more reliable, maintainable, and high-quality software development.
In the end, the debate between Pytest and Unittest isn’t about which is the top python framework is better overall but about which one is better for your specific situation. As with many tools in the software development toolkit, the best choice is often context-dependent. By considering your project's unique requirements and preferences, you can leverage these frameworks to ensure your Python code is as error-free and robust as possible.
0 notes
testcompass · 2 months
Text
Tumblr media
Did you know that with our 'early Model Based Testing (eMBT) solution TestCompass you can enrich the details of each node and test idea in your graphical model with specific test data and preconditions?
Now, the automatically generated test cases also include input values, defining different scenarios for testing edges, boundaries, and more! Plus, these details, like test data and preconditions, can be seamlessly exported to the Excel test design.
Are you curious how this works? Then ask for our free demo, and we'll demonstrate how it works using practical examples. After all, we use TestCompass ourselves as well, of course.
#testing #eMBT #MBT #testdata #testdesign #testcase #boundary #edge #TestCompass #testidea
0 notes
shiprasharma2927 · 4 months
Text
Unraveling Laravel Test: Best Practices for Efficient Coding
Tumblr media
Laravel, a powerful PHP web framework, has gained immense popularity for its elegant syntax, robust features, and developer-friendly environment. One of its key strengths lies in its testing capabilities, allowing developers to ensure the reliability and stability of their applications through automated testing. In this article, we will delve into the world of Laravel testing and explore the best practices for efficient coding.
Understanding Laravel Testing
Laravel provides a comprehensive testing suite that supports both unit and feature testing. Unit tests focus on individual components, ensuring they function correctly in isolation, while feature tests assess the behavior of multiple components working together to achieve a specific functionality.
Testing in Laravel is built on the PHPUnit framework, offering a familiar environment for developers with experience in PHPUnit. Laravel's testing tools extend PHPUnit and provide additional functionalities tailored to the Laravel ecosystem.
Best Practices for Laravel Testing
1. Isolation and Dependency Management:
When writing unit tests, it's crucial to isolate the code under test from external dependencies. Laravel's dependency injection system facilitates the use of interfaces and dependency injection, allowing you to mock external services or dependencies. This promotes testing the specific behavior of the code without relying on external factors.
phpCopy code
// Example of dependency injection in Laravel public function __construct(ExternalServiceInterface $service) { $this->service = $service; }
2. Use Factories for Data Setup:
Laravel provides a convenient way to create model instances for testing purposes using factories. Factories allow you to generate realistic data for your tests, making it easier to simulate various scenarios and edge cases.
phpCopy code
// Example of using a factory in Laravel factory(User::class)->create();
3. Database Transactions for Speed:
Wrapping your tests in a database transaction can significantly improve test speed. Laravel automatically rolls back transactions after each test, ensuring that the database remains in a consistent state. This approach reduces the overhead of migrating and seeding the database for every test.
phpCopy code
// Example of using a database transaction in Laravel use Illuminate\Foundation\Testing\DatabaseTransactions; class ExampleTest extends TestCase { use DatabaseTransactions; }
4. Test Only What Matters:
Focus your tests on critical parts of your application. Prioritize testing business logic, validation, and key functionalities. Avoid testing Laravel's built-in features, as they are already covered by the framework's own tests.
5. Organize Tests Effectively:
Keep your test suite organized by following Laravel's naming conventions. Place your test files in the tests directory and ensure that the test file names correspond to the classes they are testing. Laravel's artisan command can generate test files with the make:test command.
bashCopy code
php artisan make:test ExampleTest
6. Continuous Integration (CI):
Integrate your Laravel tests into a continuous integration system to automate the testing process. This ensures that tests are run consistently on every code change, helping to catch issues early in the development cycle.
7. Documentation and Comments:
Write clear and concise documentation for your tests, explaining the purpose of each test and any specific conditions it addresses. Additionally, use comments within your test code to provide context for future developers.
Conclusion
Laravel's testing capabilities empower developers to build robust and reliable applications. By adhering to best practices such as isolation, effective data setup, database transactions, targeted testing, organization, CI integration, and thorough documentation, developers can ensure the efficiency and effectiveness of their test suites. As you unravel the world of Laravel testing, these best practices will serve as a guide to elevate your coding standards and contribute to the overall success of your Laravel projects.
0 notes
regioonlineofficial · 6 months
Text
Een zomer lang wisselden bewoners, ondernemers, studenten en bezoekers in een Pop-Up Infopunt in Breda van gedachten over hoe de ‘VVV van morgen’ eruit moet zien. De reacties waren helder: een plek in de binnenstad die actueel, lokaal en uitnodigend is; een podium voor de verhalen en talenten van de stad. Dit participatietraject in het Pop-up Infopunt in de Bredase Houtmarkt vond plaats van 19 juli tot en met 23 september. Naast strategische sessies met verschillende partijen uit de stad kreeg iedereen met goede ideeën de gelegenheid om deze hier én online te uiten. De pop-up diende in die periode ook als tijdelijk informatiepunt en testcase voor een nieuw VVV-kantoor. Eigentijdse stadswinkel Fenne Verhoeven van Breda Marketing bemande het Pop-up Infopunt en organiseerde de sessies. Ze vertelt over de bevindingen: “Uit de gesprekken en onderzoeken komt klip en klaar naar voren dat er behoefte is aan een eigentijdse fysieke informatieplek in het centrum van Breda die meer biedt dan souvenirs en folders met fiets- en wandelroutes. Die kun je immers vaak al elders in de stad of online vinden. Bewoners en bezoekers laten zich graag verrassen met unieke stadsproducten, info over de evenementen, de verborgen (groene) plekken en nieuwe ontwikkelingen in de stad. Ze verwachten dat de ‘VVV van morgen’ de plek is waar toeristen hun dag beginnen, talenten en creatieven hun producten en verhalen delen, en je meer te weten komt over de grote ontwikkelingen in de stad. Een plek van en voor Breda dus. En hoe mooi is het als partijen uit de stad hun activiteiten hier zelf gaan presenteren aan het publiek.” Pop-up Infopunt Houtmarkt Breda - Foto: Bureau Duizenddingen i.o.v. Breda Marketing VVV in hartje centrum Op welke plek moet de ‘VVV van morgen’ eigenlijk komen? Fenne: “Er is duidelijk voorkeur voor één vaste plek in plaats van een ‘rondreizend’ infopunt. Gelegen op een centrale locatie, waarbij er ruimte is om het merk Breda zichtbaar te maken en die gemakkelijk te bereiken is vanuit het station en alle andere richtingen. Naar zo’n A-locatie gaan we de komende maanden op zoek.” Trots op Breda Het merk Breda dient als basis voor de nieuwe VVV stadswinkel. Hildegard Assies, directeur Breda Marketing, licht toe: “Breda is een geliefde stad met veel trotse Bredanaars. We houden hier van het leven. Die sfeer zal je proeven. Vooral de jonge generatie geeft aan dat er wel meer aandacht mag zijn voor inclusiviteit, diversiteit en toegankelijkheid voor iedereen. De nieuwe stadswinkel gaat hier expliciet aandacht aan geven. Ook kan deze een rol spelen in het verhogen van de gastvrijheidsbeleving in de stad, samen met ondernemers uit de horeca-, retail- en cultuursector. De stadswinkel wordt ook een fysiek en online podium waar creatieve makers, innovatie-entertainers en culturele vernieuwers elkaar ontmoeten en hun duurzame producten en verhalen kunnen etaleren.” Open in voorjaar 2024 Naast de functie van informatiepunt heeft de stadswinkel ook een aanjagende rol voor de stad. In opdracht van de gemeente Breda vertaalt Breda Marketing de inzichten en ervaringen dit najaar samen met diverse partners door in een concept voor de nieuwe stadswinkel die in het voorjaar van 2024 haar deuren opent.
0 notes
codehunter · 9 months
Text
Django Left Outer Join
I have a website where users can see a list of movies, and create reviews for them.
The user should be able to see the list of all the movies. Additionally, IF they have reviewed the movie, they should be able to see the score that they gave it. If not, the movie is just displayed without the score.
They do not care at all about the scores provided by other users.
Consider the following models.py
from django.contrib.auth.models import Userfrom django.db import modelsclass Topic(models.Model): name = models.TextField() def __str__(self): return self.nameclass Record(models.Model): user = models.ForeignKey(User) topic = models.ForeignKey(Topic) value = models.TextField() class Meta: unique_together = ("user", "topic")
What I essentially want is this
select * from bar_topicleft join (select topic_id as tid, value from bar_record where user_id = 1)on tid = bar_topic.id
Consider the following test.py for context:
from django.test import TestCasefrom bar.models import *from django.db.models import Qclass TestSuite(TestCase): def setUp(self): t1 = Topic.objects.create(name="A") t2 = Topic.objects.create(name="B") t3 = Topic.objects.create(name="C") # 2 for Johnny johnny = User.objects.create(username="Johnny") johnny.record_set.create(topic=t1, value=1) johnny.record_set.create(topic=t3, value=3) # 3 for Mary mary = User.objects.create(username="Mary") mary.record_set.create(topic=t1, value=4) mary.record_set.create(topic=t2, value=5) mary.record_set.create(topic=t3, value=6) def test_raw(self): print('\nraw\n---') with self.assertNumQueries(1): topics = Topic.objects.raw(''' select * from bar_topic left join (select topic_id as tid, value from bar_record where user_id = 1) on tid = bar_topic.id ''') for topic in topics: print(topic, topic.value) def test_orm(self): print('\norm\n---') with self.assertNumQueries(1): topics = Topic.objects.filter(Q(record__user_id=1)).values_list('name', 'record__value') for topic in topics: print(*topic)
BOTH tests should print the exact same output, however, only the raw version spits out the correct table of results:
raw---A 1B NoneC 3
the orm instead returns this
orm---A 1C 3
Any attempt to join back the rest of the topics, those that have no reviews from user "johnny", result in the following:
orm---A 1A 4B 5C 3C 6
How can I accomplish the simple behavior of the raw query with the Django ORM?
edit: This sort of works but seems very poor:
topics = Topic.objects.filter(record__user_id=1).values_list('name', 'record__value')noned = Topic.objects.exclude(record__user_id=1).values_list('name')for topic in chain(topics, noned): ...
edit: This works a little bit better, but still bad:
topics = Topic.objects.filter(record__user_id=1).annotate(value=F('record__value')) topics |= Topic.objects.exclude(pk__in=topics)
orm---A 1B 5C 3
https://codehunter.cc/a/django/django-left-outer-join
0 notes
nietzsche-glizzy · 11 months
Text
{ "translatorID": "552cdac3-f130-4763-a88e-8e74b92dcb1b", "label": "Tumblr", "creator": "febrezo", "target": "^https?://[^/]+\.tumblr\.com/", "minVersion": "3.0", "maxVersion": "", "priority": 100, "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", "lastUpdated": "2021-06-01 23:04:10" }
/* Tumblr Translator Copyright (C) 2020 Félix Brezo, [email protected] program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the Affero GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function detectWeb(doc, url) { if (url.match(/^https?:\/\/www./)) { // only try to translate subdomain blogs return false; } if (url.includes('/post/')) { return "blogPost"; } if (url.includes('/search/') && getSearchResults(doc, true)) { return "multiple"; } return "webpage"; }
function getSearchResults(doc, checkOnly) { var items = {}; var found = false; var rows = doc.querySelectorAll('#posts article'); for (let row of rows) { let href = row.querySelector('a.post-notes').href; let title = ZU.trimInternal(text(row, '.body-text p') || text(row, 'a.tag-link')); if (!href || !title) continue; if (checkOnly) return true; found = true; items[href] = title; } return found ? items : false; }
function doWeb(doc, url) { if (detectWeb(doc, url) == "multiple") { Zotero.selectItems(getSearchResults(doc, false), function (items) { if (items) ZU.processDocuments(Object.keys(items), scrape); }); } else { scrape(doc, url); } }
function scrape(doc, url) { var resourceType = detectWeb(doc, url); // Creating the item var newItem = new Zotero.Item(resourceType);var urlParts = url.split('/'); var tmpDate; if (resourceType == "blogPost") { newItem.blogTitle = ZU.xpathText(doc, "//meta[@property='og:site_name']/@content"); newItem.title = ZU.xpathText(doc, "//meta[@property='og:title']/@content"); tmpDate = ZU.xpathText(doc, '(//div[@class="date-note-wrapper"]/a)[1]'); if (!tmpDate) { tmpDate = ZU.xpathText(doc, '//div[@class="date"]/text()'); } newItem.date = ZU.strToISO(tmpDate); } else { newItem.title = ZU.xpathText(doc, "//title/text()"); newItem.websiteTitle = ZU.xpathText(doc, "//meta[@name='description']/@content"); } var tmpAuthor = urlParts[2].split(".")[0]; if (tmpAuthor) { newItem.creators.push({ lastName: tmpAuthor, creatorType: "author", fieldMode: 1 }); } newItem.websiteType = "Tumblr"; newItem.url = url; // Adding the attachment newItem.attachments.push({ title: "Tumblr Snapshot", mimeType: "text/html", url: url }); newItem.complete();
}
/** BEGIN TEST CASES / var testCases = [ { "type": "web", "url": "https://blogdeprogramacion.tumblr.com/post/167688373297/c%C3%B3mo-integrar-opencv-y-python-en-windows", "items": [ { "itemType": "blogPost", "title": "¿Cómo integrar OpenCV y Python en Windows?", "creators": [ { "lastName": "blogdeprogramacion", "creatorType": "author", "fieldMode": 1 } ], "date": "2017-11-19", "blogTitle": "Blog de Programacion y Tecnologia", "url": "https://blogdeprogramacion.tumblr.com/post/167688373297/c%C3%B3mo-integrar-opencv-y-python-en-windows", "websiteType": "Tumblr", "attachments": [ { "title": "Tumblr Snapshot", "mimeType": "text/html" } ], "tags": [], "notes": [], "seeAlso": [] } ] }, { "type": "web", "url": "https://blogdeprogramacion.tumblr.com/", "items": [ { "itemType": "webpage", "title": "Blog de Programacion y Tecnologia", "creators": [ { "lastName": "blogdeprogramacion", "creatorType": "author", "fieldMode": 1 } ], "url": "https://blogdeprogramacion.tumblr.com/", "websiteTitle": "Blog de programacion, tecnologia, electronica, tutoriales, informatica y sistemas computacionales.", "websiteType": "Tumblr", "attachments": [ { "title": "Tumblr Snapshot", "mimeType": "text/html" } ], "tags": [], "notes": [], "seeAlso": [] } ] }, { "type": "web", "url": "https://montereybayaquarium.tumblr.com/search/turtle", "items": "multiple" } ] / END TEST CASES **/
0 notes