How to use fixture3 method in Slash

Best Python code snippet using slash

test_environment_resource.py

Source:test_environment_resource.py Github

copy

Full Screen

1"""2Tests for EnvironmentResource api.3"""4from tests.case.api.crud import ApiCrudCases5import logging6logger = logging.getLogger("moztrap.test")7class EnvironmentResourceTest(ApiCrudCases):8 @property9 def factory(self):10 """The model factory for this object."""11 return self.F.EnvironmentFactory()12 @property13 def resource_name(self):14 return "environment"15 @property16 def permission(self):17 """The permissions needed to modify this object type."""18 return "environments.manage_environments"19 @property20 def new_object_data(self):21 """Generates a dictionary containing the field names and auto-generated22 values needed to create a unique object.23 The output of this method can be sent in the payload parameter of a24 POST message.25 """26 self.profile_fixture = self.F.ProfileFactory()27 self.category_fixture1 = self.F.CategoryFactory(name="A")28 self.category_fixture2 = self.F.CategoryFactory(name="B")29 self.category_fixture3 = self.F.CategoryFactory(name="C")30 self.element_fixture1 = self.F.ElementFactory(category=self.category_fixture1, name="A 2")31 self.element_fixture2 = self.F.ElementFactory(category=self.category_fixture2, name="B 2")32 self.element_fixture3 = self.F.ElementFactory(category=self.category_fixture3, name="C 2")33 self.element_fixture_list = [34 self.element_fixture1, self.element_fixture2, self.element_fixture3]35 return {36 u"profile": unicode(37 self.get_detail_url("profile", str(self.profile_fixture.id))),38 u"elements": [unicode(39 self.get_detail_url(40 "element", str(elem.id))41 ) for elem in self.element_fixture_list],42 }43 def backend_object(self, id):44 """Returns the object from the backend, so you can query it's values in45 the database for validation.46 """47 return self.model.Environment.everything.get(id=id)48 def backend_data(self, backend_obj):49 """Query's the database for the object's current values. Output is a50 dictionary that should match the result of getting the object's detail51 via the API, and can be used to verify API output.52 Note: both keys and data should be in unicode53 """54 return {55 u"id": backend_obj.id,56 u"profile": unicode(self.get_detail_url("profile", str(backend_obj.profile.id))),57 u"elements": [unicode(58 self.get_detail_url("element", str(elem.id))59 ) for elem in backend_obj.elements.all()],60 u"resource_uri": unicode(61 self.get_detail_url(self.resource_name, str(backend_obj.id))),62 }63 def test_elements_must_be_from_different_categories(self):64 """A post with two elements from the same category should error."""65 logger.info("test_elements_must_be_from_different_categories")66 # get data for creation & munge it67 fields = self.new_object_data68 self.element_fixture2.category = self.element_fixture1.category69 self.element_fixture2.save()70 # do the create71 res = self.post(72 self.get_list_url(self.resource_name),73 params=self.credentials,74 payload=fields,75 status=400,76 )77 error_msg = "Elements must each belong to a different Category."78 self.assertEqual(res.text, error_msg)79 def test_basic_combinatorics_patch(self):80 """A Patch request with profile and categories should do combinatorics81 on the categories and create environments."""82 logger.info("test_basic_combinatorics_patch")83 fields = self.new_object_data84 # create more elements for each category85 for x in range(2):86 self.F.ElementFactory(category=self.category_fixture1, name="A %s" % x)87 self.F.ElementFactory(category=self.category_fixture2, name="B %s" % x)88 self.F.ElementFactory(category=self.category_fixture3, name="C %s" % x)89 # modify fields to send categories rather than elements90 fields.pop('elements')91 fields['categories'] = [92 unicode(self.get_detail_url(93 "category", str(self.category_fixture1.id))),94 unicode(self.get_detail_url(95 "category", str(self.category_fixture2.id))),96 unicode(self.get_detail_url(97 "category", str(self.category_fixture3.id))),98 ]99 # do the create100 res = self.patch(101 self.get_list_url(self.resource_name),102 params=self.credentials,103 payload=fields,104 )105 # check that it made the right number of environments106 self._test_filter_list_by(u'profile', self.profile_fixture.id, 27)107 def test_patch_without_categories_error(self):108 """'categories' must be provided in PATCH."""109 logger.info("test_patch_without_categories_error")110 fields = self.new_object_data111 # do the create112 res = self.patch(113 self.get_list_url(self.resource_name),114 params=self.credentials,115 payload=fields,116 status=400,117 )118 error_msg = "PATCH request must contain categories list."119 self.assertEqual(res.text, error_msg)120 def test_patch_categories_not_list_error(self):121 """'categories' must be a list in PATCH."""122 logger.info("test_patch_categories_not_list_error")123 fields = self.new_object_data124 fields.pop("elements")125 fields[u'categories'] = unicode(126 self.get_detail_url("category", str(self.category_fixture1.id)))127 # do the create128 res = self.patch(129 self.get_list_url(self.resource_name),130 params=self.credentials,131 payload=fields,132 status=400,133 )134 error_msg = "PATCH request must contain categories list."135 self.assertEqual(res.text, error_msg)136 def test_patch_categories_list_not_string_or_hash_error(self):137 """'categories' must be a list in PATCH."""138 logger.info("test_patch_categories_list_not_string_or_hash_error")139 fields = self.new_object_data140 fields.pop("elements")141 fields[u'categories'] = [1, 2, 3]142 # do the create143 res = self.patch(144 self.get_list_url(self.resource_name),145 params=self.credentials,146 payload=fields,147 status=400,148 )149 error_msg = "categories list must contain resource uris or hashes."150 self.assertEqual(res.text, error_msg)151 def test_patch_with_exclude(self):152 """Combinatorics excluding some elements."""153 logger.info("test_patch_with_exclude")154 fields = self.new_object_data155 # create more elements for each category156 for x in range(2):157 self.F.ElementFactory(category=self.category_fixture1, name="A %s" % x)158 self.F.ElementFactory(category=self.category_fixture2, name="B %s" % x)159 self.F.ElementFactory(category=self.category_fixture3, name="C %s" % x)160 # modify fields to send categories rather than elements161 fields.pop('elements')162 fields['categories'] = [163 {164 u'category': unicode(self.get_detail_url(165 "category", str(self.category_fixture1.id))),166 u'exclude': [unicode(self.get_detail_url(167 "element", str(self.element_fixture1.id))), ],168 },169 {170 u'category': unicode(self.get_detail_url(171 "category", str(self.category_fixture2.id))),172 u'exclude': [unicode(self.get_detail_url(173 "element", str(self.element_fixture2.id))), ],174 },175 {176 u'category': unicode(self.get_detail_url(177 "category", str(self.category_fixture3.id))),178 u'exclude': [unicode(self.get_detail_url(179 "element", str(self.element_fixture3.id))), ],180 }, ]181 # do the create182 res = self.patch(183 self.get_list_url(self.resource_name),184 params=self.credentials,185 payload=fields,186 )187 # check that it made the right number of environments188 self._test_filter_list_by(u'profile', self.profile_fixture.id, 8)189 def test_patch_with_include(self):190 """Combinatorics including some elements."""191 logger.info("test_patch_with_include")192 fields = self.new_object_data193 # create more elements for each category194 for x in range(2):195 self.F.ElementFactory(category=self.category_fixture1, name="A %s" % x)196 self.F.ElementFactory(category=self.category_fixture2, name="B %s" % x)197 self.F.ElementFactory(category=self.category_fixture3, name="C %s" % x)198 # modify fields to send categories rather than elements199 fields.pop('elements')200 fields['categories'] = [201 {202 u'category': unicode(self.get_detail_url(203 "category", str(self.category_fixture1.id))),204 u'include': [unicode(self.get_detail_url(205 "element", str(self.element_fixture1.id))), ],206 },207 {208 u'category': unicode(self.get_detail_url(209 "category", str(self.category_fixture2.id))),210 u'include': [unicode(self.get_detail_url(211 "element", str(self.element_fixture2.id))), ],212 },213 {214 u'category': unicode(self.get_detail_url(215 "category", str(self.category_fixture3.id))),216 u'include': [unicode(self.get_detail_url(217 "element", str(self.element_fixture3.id))), ],218 }, ]219 # do the create220 res = self.patch(221 self.get_list_url(self.resource_name),222 params=self.credentials,223 payload=fields,224 )225 # check that it made the right number of environments226 self._test_filter_list_by(u'profile', self.profile_fixture.id, 1)227 def test_patch_no_include_no_exclude(self):228 """Sending hashes without include or exclude should do the same as229 sending regular uri strings."""230 logger.info("test_patch_no_include_no_exclude")231 fields = self.new_object_data232 # create more elements for each category233 for x in range(2):234 self.F.ElementFactory(category=self.category_fixture1, name="A %s" % x)235 self.F.ElementFactory(category=self.category_fixture2, name="B %s" % x)236 self.F.ElementFactory(category=self.category_fixture3, name="C %s" % x)237 # modify fields to send categories rather than elements238 fields.pop('elements')239 fields['categories'] = [240 {241 u'category': unicode(self.get_detail_url(242 "category", str(self.category_fixture1.id))),243 },244 {245 u'category': unicode(self.get_detail_url(246 "category", str(self.category_fixture2.id))),247 },248 {249 u'category': unicode(self.get_detail_url(250 "category", str(self.category_fixture3.id))),251 }, ]252 # do the create253 res = self.patch(254 self.get_list_url(self.resource_name),255 params=self.credentials,256 payload=fields,257 )258 # check that it made the right number of environments...

Full Screen

Full Screen

child-checkin.component.spec.ts

Source:child-checkin.component.spec.ts Github

copy

Full Screen

1import { ChildCheckinComponent } from './child-checkin.component';2import { Child, Event, Room } from '../shared/models';3import { RootService } from '../shared/services';4import { Observable } from 'rxjs/Observable';5let fixture: ChildCheckinComponent;6const event = { EventId: '123', EventStartDate: '2016-11-22 10:00:00', IsCurrentEvent: false };7const event2 = { EventId: '456', EventStartDate: '2016-11-22 09:00:00', IsCurrentEvent: false };8const eventCurrent = { EventId: 789, EventStartDate: '2016-11-22 08:00:00', IsCurrentEvent: true };9let setupService = jasmine.createSpyObj('setupService', ['getMachineDetailsConfigCookie']);10setupService.getMachineDetailsConfigCookie.and.returnValue({RoomId: 123});11let apiService = jasmine.createSpyObj('apiService', ['getEvents']);12let childCheckinService = jasmine.createSpyObj('ChildCheckinService', ['selectEvent', 'getChildByCallNumber', 'getEventRoomDetails']);13let rootService = jasmine.createSpyObj<RootService>('rootService', ['announceEvent']);14let channelService = jasmine.createSpyObj('channelService', ['sub', 'unsubAll']);15describe('ChildCheckinComponent', () => {16 describe('#ngOnInit', () => {17 describe('initalization', () => {18 beforeEach(() => {19 apiService.getEvents.and.returnValue(Observable.of([new Event(), new Event()]));20 channelService.sub.and.returnValue(Observable.of([{}]));21 childCheckinService.getEventRoomDetails.and.returnValue(Observable.of([{}]));22 fixture = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);23 // fixture.selectedEvent = new Event();24 });25 it('should set kiosk config details from cookie and get today\'s events', () => {26 fixture.ngOnInit();27 expect(setupService.getMachineDetailsConfigCookie).toHaveBeenCalled();28 expect(apiService.getEvents).toHaveBeenCalled();29 });30 });31 describe('setting the current event', () => {32 describe('and there is a current event', () => {33 beforeEach(() => {34 apiService.getEvents.and.returnValue(Observable.of([event, eventCurrent]));35 fixture = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);36 });37 it('should set where IsCurrentEvent is true', () => {38 fixture.ngOnInit();39 expect(fixture.selectedEvent.EventId).toEqual(eventCurrent.EventId);40 });41 });42 describe('and there is no current event', () => {43 let fixture2;44 beforeEach(() => {45 childCheckinService = jasmine.createSpyObj('ChildCheckinService', ['selectEvent', 'getEventRoomDetails']);46 childCheckinService.getEventRoomDetails.and.returnValue(Observable.of([{}]));47 apiService.getEvents.and.returnValue(Observable.of([event, event2]));48 fixture2 = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);49 });50 it('should set first when no IsCurrentEvent', () => {51 fixture2.ngOnInit();52 expect(fixture2.selectedEvent.EventId).toEqual(event.EventId);53 });54 });55 describe('override modal', () => {56 let fixture3;57 let fakeModal = { show: {}, hide: {} };58 beforeEach(() => {59 childCheckinService = jasmine.createSpyObj('ChildCheckinService',60 ['getChildByCallNumber', 'forceChildReload', 'overrideChildIntoRoom', 'getEventRoomDetails']);61 childCheckinService.getChildByCallNumber.and.returnValue(Observable.of());62 childCheckinService.forceChildReload.and.returnValue(Observable.of());63 childCheckinService.overrideChildIntoRoom.and.returnValue(Observable.of(new Child()));64 childCheckinService.getEventRoomDetails.and.returnValue(Observable.of(new Room()));65 fixture3 = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);66 fixture3.callNumber = '431';67 fixture3.overrideChild = new Child();68 fixture3.overrideChild.EventParticipantId = 444;69 fixture3.kioskDetails = { RoomId: 444 };70 spyOn(fakeModal, 'show').and.callFake(() => {});71 spyOn(fakeModal, 'hide').and.callFake(() => {});72 fixture3.childSearchModal = fakeModal;73 fixture3.selectedEvent = new Event();74 fixture3.selectedEvent.EventId = 333;75 });76 describe('#delete', () => {77 it('should delete a digit from call number', () => {78 fixture3.delete();79 expect(fixture3.callNumber).toEqual('43');80 });81 });82 describe('#clear', () => {83 it('should clear call number', () => {84 fixture3.clear();85 expect(fixture3.callNumber).toEqual('');86 });87 });88 describe('#resetShowChildModal', () => {89 it('should remove override child if defined', () => {90 expect(fixture3.overrideChild.EventParticipantId).toEqual(444);91 fixture3.resetShowChildModal();92 expect(fixture3.overrideChild.EventParticipantId).not.toBeDefined();93 });94 });95 describe('#setCallNumber', () => {96 beforeEach(() => {97 channelService.sub.and.returnValue(Observable.of([{}]));98 });99 it('should set the call number and call override checkin if four digits', () => {100 fixture3.selectedEvent = new Event();101 fixture3.selectedEvent.EventId = 333;102 fixture3.setCallNumber('8');103 expect(fixture3.callNumber).toEqual('4318');104 expect(childCheckinService.getChildByCallNumber).toHaveBeenCalledWith(333, '4318', 444);105 });106 });107 describe('#overrideCheckin', () => {108 describe('success', () => {109 it('should hide modal, show message, call to have children reload', () => {110 fixture3.overrideCheckin();111 expect(fakeModal.hide).toHaveBeenCalled();112 expect(rootService.announceEvent).toHaveBeenCalledWith('checkinOverrideSuccess');113 expect(childCheckinService.forceChildReload).toHaveBeenCalled();114 });115 });116 describe('error (room over capacity)', () => {117 beforeEach(() => {118 childCheckinService.overrideChildIntoRoom.and.returnValue(Observable.throw('capacity'));119 fixture3 = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);120 });121 it('should show specific error message', () => {122 fixture3.overrideCheckin();123 expect(rootService.announceEvent).toHaveBeenCalledWith('checkinOverrideRoomCapacityError');124 });125 });126 describe('error (room closed)', () => {127 beforeEach(() => {128 childCheckinService.overrideChildIntoRoom.and.returnValue(Observable.throw('closed'));129 fixture3 = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);130 });131 it('should show specific error message', () => {132 fixture3.overrideCheckin();133 expect(rootService.announceEvent).toHaveBeenCalledWith('checkinOverrideRoomClosedError');134 });135 });136 describe('error (general)', () => {137 beforeEach(() => {138 childCheckinService.overrideChildIntoRoom.and.returnValue(Observable.throw('error!'));139 fixture3 = new ChildCheckinComponent(setupService, apiService, childCheckinService, rootService, channelService);140 });141 it('should show specific error message', () => {142 fixture3.overrideCheckin();143 expect(rootService.announceEvent).toHaveBeenCalledWith('generalError');144 });145 });146 });147 });148 });149 });...

Full Screen

Full Screen

FixturesSpec.js

Source:FixturesSpec.js Github

copy

Full Screen

1describe("App.Collections.Fixtures", function() {2 var fixtures;3 afterEach(function() {4 fixtures = null;5 });6 describe("sorting", function() {7 var fixture1, fixture2, fixture3;8 beforeEach(function() {9 // NOTE: date variance done in years10 fixture1 = new App.Modelss.Fixture({11 time: "2001-01-01T12:00:00Z"12 });13 fixture2 = new App.Modelss.Fixture({14 time: "2002-01-01T12:00:00Z"15 });16 fixture3 = new App.Modelss.Fixture({17 time: "2003-01-01T12:00:00Z"18 });19 });20 afterEach(function() {21 fixture1.destroy();22 fixture2.destroy();23 fixture3.destroy();24 });25 it("can sort in ascending order", function() {26 var options = {27 ascendingOrder: true28 };29 fixtures = new App.Collections.Fixtures([fixture3, fixture1, fixture2], options);30 expect(fixtures.at(0)).toBe(fixture1);31 expect(fixtures.at(1)).toBe(fixture2);32 expect(fixtures.at(2)).toBe(fixture3);33 });34 it("can sort in descending order", function() {35 var options = {36 ascendingOrder: false37 };38 fixtures = new App.Collections.Fixtures([fixture3, fixture1, fixture2], options);39 expect(fixtures.at(0)).toBe(fixture3);40 expect(fixtures.at(1)).toBe(fixture2);41 expect(fixtures.at(2)).toBe(fixture1);42 });43 });44 describe("filtering", function() {45 var futureFixture, pastFixture;46 beforeEach(function() {47 var year = moment().year();48 futureFixture = new App.Modelss.Fixture({49 time: (year + 1) + "-01-01T12:00:00Z"50 });51 pastFixture = new App.Modelss.Fixture({52 time: (year - 1) + "-01-01T12:00:00Z"53 });54 fixtures = new App.Collections.Fixtures([futureFixture, pastFixture]);55 });56 afterEach(function() {57 futureFixture.destroy();58 pastFixture.destroy();59 });60 it("can get only future fixtures", function() {61 var futureFixtures = fixtures.getFixtures(true);62 expect(fixtures.length).toEqual(2);63 expect(futureFixtures.length).toEqual(1);64 expect(futureFixtures[0]).toBe(futureFixture);65 });66 it("can get only past fixtures", function() {67 var pastFixtures = fixtures.getFixtures(false);68 expect(fixtures.length).toEqual(2);69 expect(pastFixtures.length).toEqual(1);70 expect(pastFixtures[0]).toBe(pastFixture);71 });72 });...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...5import fixture3 from './fixture3.js';6test('main', t => {7 t.is(path.basename(fixture().getFileName()), 'test.js');8 t.is(path.basename(fixture2().getFileName()), 'test.js');9 t.is(path.basename(fixture3().getFileName()), 'test.js');10 t.is(path.basename(fixture3({depth: 1}).getFileName()), 'test.js');11 t.is(path.basename(fixture3({depth: 2}).getFileName()), 'fixture3.js');12 t.is(path.basename(fixture3({depth: 3}).getFileName()), 'fixture2.js');13 t.is(path.basename(fixture3({depth: 4}).getFileName()), 'fixture.js');14 t.is(path.basename(fixture3({depth: 5}).getFileName()), 'index.js');...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful