def test_links_attribute_is_set_to_none(self):
     """testing if a TypeError will be raised when the links attribute is
     set to None
     """
     daily = Daily(name='Test Daily', project=self.test_project)
     with self.assertRaises(TypeError):
         daily.links = None
Exemple #2
0
 def test_links_attribute_is_set_to_none(self):
     """testing if a TypeError will be raised when the links attribute is
     set to None
     """
     daily = Daily(name='Test Daily', project=self.test_project)
     with self.assertRaises(TypeError):
         daily.links = None
 def test_tasks_attribute_will_return_a_list_of_tasks(self):
     """testing if the tasks attribute is a list of Task instances related
     to the given links
     """
     daily = Daily(name='Test Daily', project=self.test_project)
     daily.links = [self.test_link1, self.test_link2]
     db.DBSession.add(daily)
     db.DBSession.commit()
     self.assertEqual(daily.tasks, [self.test_task1])
Exemple #4
0
 def test_tasks_attribute_will_return_a_list_of_tasks(self):
     """testing if the tasks attribute is a list of Task instances related
     to the given links
     """
     daily = Daily(name='Test Daily', project=self.test_project)
     daily.links = [self.test_link1, self.test_link2]
     db.DBSession.add(daily)
     db.DBSession.commit()
     self.assertEqual(daily.tasks, [self.test_task1])
Exemple #5
0
 def test_versions_attribute_will_return_a_list_of_versions(self):
     """testing if the versions attribute is a list of Version instances
     related to the given links
     """
     from stalker import db, Daily
     daily = Daily(name='Test Daily', project=self.test_project)
     daily.links = [self.test_link1, self.test_link2]
     db.DBSession.add(daily)
     db.DBSession.commit()
     self.assertEqual(daily.versions, [self.test_version1])
Exemple #6
0
 def test_links_attribute_is_set_to_none(self):
     """testing if a TypeError will be raised when the links attribute is
     set to None
     """
     from stalker import Daily
     daily = Daily(name='Test Daily',
                   project=self.test_project,
                   status_list=self.daily_status_list)
     with pytest.raises(TypeError):
         daily.links = None
Exemple #7
0
 def test_versions_attribute_will_return_a_list_of_versions(self):
     """testing if the versions attribute is a list of Version instances
     related to the given links
     """
     from stalker import Daily
     daily = Daily(name='Test Daily',
                   project=self.test_project,
                   status_list=self.daily_status_list)
     daily.links = [self.test_link1, self.test_link2]
     from stalker.db.session import DBSession
     DBSession.add(daily)
     DBSession.commit()
     assert daily.versions == [self.test_version1]
Exemple #8
0
 def test_links_argument_is_none(self):
     """testing if the links attribute will be an empty list when the links
     argument is None
     """
     from stalker import Daily
     daily = Daily(name='Test Daily', links=None, project=self.test_project)
     self.assertEqual(daily.links, [])
Exemple #9
0
 def test_versions_attribute_is_read_only(self):
     """testing if versions attribute is a read only attribute
     """
     from stalker import Daily
     daily = Daily(name='Test Daily', project=self.test_project)
     with self.assertRaises(AttributeError):
         setattr(daily, 'versions', 10)
Exemple #10
0
    def test_links_attribute_is_working_properly(self):
        """testing if the links attribute is working properly
        """
        daily = Daily(name='Test Daily', project=self.test_project)
        daily.links.append(self.test_link1)

        self.assertEqual(daily.links, [self.test_link1])
Exemple #11
0
 def test_daily_instance_creation(self):
     """testing if it is possible to create a Daily without a problem
     """
     from stalker import Daily
     daily = Daily(name='Test Daily',
                   project=self.test_project,
                   status_list=self.daily_status_list)
     assert isinstance(daily, Daily)
Exemple #12
0
 def test_links_argument_is_skipped(self):
     """testing if the links attribute will be an empty list if the links
     argument is skipped
     """
     from stalker import Daily
     daily = Daily(name='Test Daily',
                   project=self.test_project,
                   status_list=self.daily_status_list)
     assert daily.links == []
Exemple #13
0
 def test_links_argument_is_working_properly(self):
     """testing if the links argument value is correctly passed to the links
     attribute
     """
     test_value = [self.test_link1, self.test_link2]
     daily = Daily(name='Test Daily',
                   links=test_value,
                   project=self.test_project)
     self.assertEqual(daily.links, test_value)
Exemple #14
0
    def test_links_attribute_is_working_properly(self):
        """testing if the links attribute is working properly
        """
        from stalker import Daily
        daily = Daily(name='Test Daily',
                      project=self.test_project,
                      status_list=self.daily_status_list)
        daily.links.append(self.test_link1)

        assert daily.links == [self.test_link1]
Exemple #15
0
 def test_links_argument_is_working_properly(self):
     """testing if the links argument value is correctly passed to the links
     attribute
     """
     test_value = [self.test_link1, self.test_link2]
     from stalker import Daily
     daily = Daily(name='Test Daily',
                   links=test_value,
                   project=self.test_project,
                   status_list=self.daily_status_list)
     assert daily.links == test_value
Exemple #16
0
    def test_links_argument_is_not_a_list_of_link_instances(self):
        """testing if a TypeError will be raised when the links argument is not
        a list of Link instances
        """
        with self.assertRaises(TypeError) as cm:
            Daily(name='Test Daily',
                  links=['not', 1, 'list', 'of', Daily, 'instances'],
                  project=self.test_project)

        self.assertEqual(
            str(cm.exception),
            'DailyLink.link should be an instance of stalker.models.link.Link '
            'instance, not str')
Exemple #17
0
    def test_links_argument_is_not_a_list_of_link_instances(self):
        """testing if a TypeError will be raised when the links argument is not
        a list of Link instances
        """
        from stalker import Daily
        with pytest.raises(TypeError) as cm:
            Daily(name='Test Daily',
                  links=['not', 1, 'list', 'of', Daily, 'instances'],
                  project=self.test_project,
                  status_list=self.daily_status_list)

        assert str(cm.value) == \
            'DailyLink.link should be an instance of ' \
            'stalker.models.link.Link instance, not str'
Exemple #18
0
    def test_links_argument_is_not_a_list_instance(self):
        """testing if a TypeError will be raised when the links argument is not
        a list
        """
        from stalker import Daily
        with self.assertRaises(TypeError) as cm:
            Daily(name='Test Daily',
                  links='not a list of Daily instances',
                  project=self.test_project)

        self.assertEqual(
            str(cm.exception),
            'DailyLink.link should be an instance of stalker.models.link.Link '
            'instance, not str')
Exemple #19
0
def create_daily(request):
    """runs when creating a daily
    """

    logged_in_user = get_logged_in_user(request)
    utc_now = local_to_utc(datetime.datetime.now())

    name = request.params.get('name')
    description = request.params.get('description')

    status_id = request.params.get('status_id')
    status = Status.query.filter(Status.id == status_id).first()

    project_id = request.params.get('project_id', None)
    project = Project.query.filter(Project.id == project_id).first()

    if not name:
        return Response('Please supply a name', 500)

    if not description:
        return Response('Please supply a description', 500)

    if not status:
        return Response('There is no status with code: %s' % status_id, 500)

    if not project:
        return Response('There is no project with id: %s' % project_id, 500)

    daily = Daily(project=project,
                  name=name,
                  status=status,
                  description=description,
                  created_by=logged_in_user,
                  date_created=utc_now,
                  date_updated=utc_now)
    from stalker.db.session import DBSession
    DBSession.add(daily)

    return Response('Daily Created successfully')
Exemple #20
0
 def test_links_argument_is_skipped(self):
     """testing if the links attribute will be an empty list if the links
     argument is skipped
     """
     daily = Daily(name='Test Daily', project=self.test_project)
     self.assertEqual(daily.links, [])
Exemple #21
0
 def test_daily_instance_creation(self):
     """testing if it is possible to create a Daily without a problem
     """
     daily = Daily(name='Test Daily', project=self.test_project)
     self.assertTrue(isinstance(daily, Daily))