예제 #1
0
 def test_create_valid_full(self):
     Route.objects.create(operator=Company.create_owned_company(
         name="Testbahn", abbrev="TB", owners=login_user(self)),
                          name=self.DEMO_ROUTE_NAME,
                          type=Route.LONG_DISTANCE,
                          revenue_per_week=5000.00,
                          start_date=now(),
                          end_date=now() + timedelta(days=2 * 365))
예제 #2
0
 def test_create_company_valid_two_owners(self):
     login_user(self)
     first_user = self.user
     login_user(context=self, username='******')
     second_user = self.user
     company = Company.create_owned_company(name="Testbahn", abbrev="TB", owners=[first_user, second_user])
     self.assertEquals(first_user.company_set.all().count(), 1)
     self.assertEquals(second_user.company_set.all().count(), 1)
     self.assertEquals(company.ownership.all().count(), 2)
예제 #3
0
 def test_to_string_full(self):
     route = Route(operator=Company.create_owned_company(
         name="Testbahn", abbrev="TB", owners=login_user(self)),
                   name=self.DEMO_ROUTE_NAME,
                   type=Route.LONG_DISTANCE,
                   revenue_per_week=5000.00,
                   start_date=now(),
                   end_date=now() + timedelta(days=2 * 365))
     self.assertEquals(route.__str__(),
                       'KBS 100 Hamburg - Rostock (Testbahn)')
 def form_valid(self, form):
     Company.create_owned_company(form.data['name'], form.data['abbrev'], self.request.user)
     return redirect('index')
예제 #5
0
 def test_create_company_to_string(self):
     login_user(self)
     company = Company.create_owned_company(name="TestBahn", abbrev="TB", owners=self.user)
     self.assertEquals(company.__str__(), "TestBahn (TB)")
예제 #6
0
    def test_create_company_duplicate_abbrev(self):
        login_user(self)
        Company.create_owned_company(name="Testbahn", abbrev="TB", owners=self.user)

        with self.assertRaises(IntegrityError, msg="Adding a company with existing abbreviation, should not work"):
            Company.create_owned_company(name="Tolle Bahn", abbrev="TB", owners=self.user)
예제 #7
0
 def test_create_company_valid_one_owner(self):
     login_user(self)
     Company.create_owned_company(name="Testbahn", abbrev="TB", owners=self.user)
     self.assertEquals(self.user.company_set.all().count(), 1)