Ejemplo n.º 1
0
    def create_factories(self):
        self.user = UserWithHostFactory()
        self.ip = self.user.hosts[0].interfaces[0].ips[0]
        for delta in range(14):
            TrafficCreditFactory.create(timestamp=self.now + timedelta(-delta),
                                        amount=3*1024**3, user=self.user)
            TrafficVolumeFactory.create(timestamp=self.now + timedelta(-delta),
                                        amount=1*1024**3, user=self.user, ip=self.ip)

        # Unrelated events should not be included in the sum
        other_user = UserWithHostFactory()
        other_ip = other_user.hosts[0].interfaces[0].ips[0]
        TrafficCreditFactory.create_batch(20, user=other_user)
        TrafficVolumeFactory.create_batch(20, user=other_user, ip=other_ip)
Ejemplo n.º 2
0
    def test_user_host_annexation(self):
        mac = "00:de:ad:be:ef:00"
        other_user = UserWithHostFactory(host__interface__mac=mac)
        session.session.commit()
        self.assertEqual(len(other_user.hosts), 1)

        move_in_formdata = {
            'now': True,
            'name': "Test User",
            'building': str(self.room.building.id),
            'level': str(self.room.level),
            'room_number': self.room.number,
            'login': "******",
            'mac': mac,
            'email': "",
            'birthdate': "1990-01-01",
            'property_group': config.member_group.id
        }
        response = self.client.post(url_for('user.create'),
                                    data=move_in_formdata)
        self.assertStatus(response, 400)
        self.assertIsNone(response.location)

        move_in_formdata.update(annex="y")
        response = self.client.post(url_for('user.create'),
                                    data=move_in_formdata)
        self.assert_user_moved_in(response)
Ejemplo n.º 3
0
 def create_factories(self):
     super().create_factories()
     self.relevant_user = UserWithHostFactory(patched=True)
     self.other_user = UserFactory.create()
     self.room_log_entry = RoomLogEntryFactory(author=self.admin,
                                               room=self.relevant_user.room)
     self.user_log_entry = UserLogEntryFactory(author=self.admin,
                                               user=self.relevant_user)
Ejemplo n.º 4
0
 def create_factories(self):
     super().create_factories()
     # we just create the subnet to ensure it stays the same when in the same building
     subnet = factories.SubnetFactory()
     self.user = UserWithHostFactory(
         room__patched_with_subnet=True,
         room__patch_ports__switch_port__default_vlans__subnets=[subnet])
     self.processing_user = UserFactory()
     self.old_room = self.user.room
     assert all(h.room == self.old_room for h in self.user.hosts)
     self.new_room_other_building = factories.RoomFactory(
         patched_with_subnet=True)
     self.new_room_same_building = factories.RoomFactory(
         building=self.old_room.building,
         patched_with_subnet=True,
         patch_ports__switch_port__default_vlans__subnets=[subnet],
     )
Ejemplo n.º 5
0
 def create_factories(self):
     self.user = UserWithHostFactory(host__interface__ip__str_address=self.ip)
Ejemplo n.º 6
0
 def test_user_without_entries_has_zero_credit(self):
     user = UserWithHostFactory()
     session.session.commit()
     self.assertEqual(user.current_credit, 0)
Ejemplo n.º 7
0
def user(module_session):
    return UserWithHostFactory(host__interface__ip__str_address=ip)
Ejemplo n.º 8
0
def user(module_session):
    return UserWithHostFactory()
Ejemplo n.º 9
0
 def create_factories(self):
     super().create_factories()
     self.user = UserWithHostFactory()
     TrafficVolumeLastWeekFactory.create_batch(
         7, ip=self.user.hosts[0].interfaces[0].ips[0], user=self.user)