def test_context_data(self): # Імітуємо будинок з одної квартири: floors = ['0'] entrances = ['1'] flat = Flat(floor_No=0, entrance_No=1) flat.save() block_scheme = { '0': { '1': [ flat, ] } } # {0: {1: [flat, ], 2: [flat, ]}, 1: {1: [flat, ], 2: [flat, ]},} block_length = {'1': 1} kwargs = { 'block_scheme': block_scheme, 'block_length': block_length, 'floors': floors, 'entrances': entrances, } # Setup request and view. request = RequestFactory().get('/flats/scheme/') view = FlatScheme() view = setup_view(view, request, kwargs) # Run. context = view.get_context_data() # Check. self.assertEqual(context['block_scheme'], block_scheme) self.assertEqual(context['block_length'], block_length) self.assertEqual(context['floors'], floors) self.assertEqual(context['entrances'], entrances)
def test_context_data_3(self): # Імітуємо будинок з кількох квартир: floors = (1, 2) entrances = (1, 2) DummyFlat().create_dummy_building(floors=floors, entrances=entrances) d, floors, entrances = flats.views.block_scheme() l = flats.views.block_length(d) kwargs = { 'block_scheme': d, 'block_length': l, 'floors': floors, 'entrances': entrances, } # dict_print(kwargs, 'kwargs') # Setup request and view. request = RequestFactory().get('/flats/scheme/') view = FlatScheme() view = setup_view(view, request, kwargs) # Run. context = view.get_context_data() # Check. self.assertEqual(context['block_scheme'], d) self.assertEqual(context['block_length'], l) self.assertEqual(context['floors'], floors) self.assertEqual(context['entrances'], entrances)
def test_context_data_2(self): # Імітуємо будинок з кількох квартир: flat1 = Flat(floor_No=1, entrance_No=1) flat1.save() flat2 = Flat(floor_No=2, entrance_No=2) flat2.save() flat3 = Flat(floor_No=2, entrance_No=2) flat3.save() floors = ['2', '1'] entrances = ['1', '2'] block_scheme = {'1': {'1': [flat1]}, '2': {'2': [flat2, flat3]}} # {0: {1: [flat, ], 2: [flat, ]}, 1: {1: [flat, ], 2: [flat, ]},} block_length = {'1': 1, '2': 2} kwargs = { 'block_scheme': block_scheme, 'block_length': block_length, 'floors': floors, 'entrances': entrances, } # Setup request and view. request = RequestFactory().get('/flats/scheme/') view = FlatScheme() view = setup_view(view, request, kwargs) # Run. context = view.get_context_data() # Check. self.assertEqual(context['block_scheme'], block_scheme) self.assertEqual(context['block_length'], block_length) self.assertEqual(context['floors'], floors) self.assertEqual(context['entrances'], entrances)
def test_context_data_2(self): # Імітуємо будинок з кількох квартир: flat1 = Flat(floor_No=1, entrance_No=1) flat1.save() flat2 = Flat(floor_No=2, entrance_No=2) flat2.save() flat3 = Flat(floor_No=2, entrance_No=2) flat3.save() floors = ["2", "1"] entrances = ["1", "2"] block_scheme = {"1": {"1": [flat1]}, "2": {"2": [flat2, flat3]}} # {0: {1: [flat, ], 2: [flat, ]}, 1: {1: [flat, ], 2: [flat, ]},} block_length = {"1": 1, "2": 2} kwargs = {"block_scheme": block_scheme, "block_length": block_length, "floors": floors, "entrances": entrances} # Setup request and view. request = RequestFactory().get("/flats/scheme/") view = FlatScheme() view = setup_view(view, request, kwargs) # Run. context = view.get_context_data() # Check. self.assertEqual(context["block_scheme"], block_scheme) self.assertEqual(context["block_length"], block_length) self.assertEqual(context["floors"], floors) self.assertEqual(context["entrances"], entrances)
def test_context_data_3(self): # Імітуємо будинок з кількох квартир: floors = (1, 2) entrances = (1, 2) DummyFlat().create_dummy_building(floors=floors, entrances=entrances) d, floors, entrances = flats.views.block_scheme() l = flats.views.block_length(d) kwargs = {"block_scheme": d, "block_length": l, "floors": floors, "entrances": entrances} # dict_print(kwargs, 'kwargs') # Setup request and view. request = RequestFactory().get("/flats/scheme/") view = FlatScheme() view = setup_view(view, request, kwargs) # Run. context = view.get_context_data() # Check. self.assertEqual(context["block_scheme"], d) self.assertEqual(context["block_length"], l) self.assertEqual(context["floors"], floors) self.assertEqual(context["entrances"], entrances)
def test_context_data(self): # Імітуємо будинок з одної квартири: floors = ["0"] entrances = ["1"] flat = Flat(floor_No=0, entrance_No=1) flat.save() block_scheme = {"0": {"1": [flat]}} # {0: {1: [flat, ], 2: [flat, ]}, 1: {1: [flat, ], 2: [flat, ]},} block_length = {"1": 1} kwargs = {"block_scheme": block_scheme, "block_length": block_length, "floors": floors, "entrances": entrances} # Setup request and view. request = RequestFactory().get("/flats/scheme/") view = FlatScheme() view = setup_view(view, request, kwargs) # Run. context = view.get_context_data() # Check. self.assertEqual(context["block_scheme"], block_scheme) self.assertEqual(context["block_length"], block_length) self.assertEqual(context["floors"], floors) self.assertEqual(context["entrances"], entrances)
from django.conf.urls import url from flats.views import FlatList, FlatScheme, \ FlatDetail, FlatDetailHorizontal, \ FlatTable, \ FlatSchemeUsers, FlatUsersList from koopsite.views import page_not_ready """ /flats/ - під'єднано у модулі koopsite.urls.py: url(r'^flats/', include('flats.urls')), """ urlpatterns = [ url(r'^list/$', FlatList.as_view(), name='flat-list'), url(r'^scheme/$', FlatScheme.as_view(), name='flat-scheme'), url(r'^(?P<pk>[0-9]+)/$', FlatDetail.as_view(), name='flat-detail'), url(r'^(?P<pk>[0-9]+)/h/$', FlatDetailHorizontal.as_view(), name='flat-detail-h'), url(r'^table/$', FlatTable.as_view(), name='flat-table'), url(r'^scheme-users/$', FlatSchemeUsers.as_view(), name='flat-scheme-users'), url(r'^(?P<pk>[0-9]+)/users-list/$', FlatUsersList.as_view(), name='flat-users-list'), #--------- Кінець коду, охопленого функціональними тестами ------------ # url(r'^person/table/$', PersonTableView.as_view(), name='person-table'), url(r'^person/table/$', page_not_ready, name='person-table'), ] # urlpatterns += staticfiles_urlpatterns()