コード例 #1
0
ファイル: test_manager.py プロジェクト: warlof/allianceauth
    def test_get_fleetup_timers(self, get_endpoint):

        get_endpoint.return_value = {
            "Data": [{
                'ExpiresString': '2017-05-06 11:11:11',
                'SolarSystem': 'Jita',
                'Planet': '4',
                'Moon': '4',
                'Owner': 'Caldari Navy',
                'Type': 'Caldari Station',
                'TimerType': 'Armor',
                'Notes': 'Burn Jita?'
            }]
        }

        # Act
        result = FleetUpManager.get_fleetup_timers()

        # Asset
        self.assertTrue(get_endpoint.called)
        args, kwargs = get_endpoint.call_args
        self.assertEqual(
            args[0],
            FleetUpManager.BASE_URL + '/Timers/' + FleetUpManager.GROUP_ID)
        expected_result = {
            '2017-05-06 11:11:11': {
                'expires': datetime.datetime(2017, 5, 6, 11, 11, 11),
                'solarsystem': 'Jita',
                'planet': '4',
                'moon': '4',
                'owner': 'Caldari Navy',
                'type': 'Caldari Station',
                'timer_type': 'Armor',
                'notes': 'Burn Jita?'
            }
        }
        self.assertDictEqual(expected_result, result)

        # Test None response
        # Arrange
        get_endpoint.return_value = None

        # Act
        result = FleetUpManager.get_fleetup_timers()

        # Assert
        self.assertIsNone(result)

        # Test Empty response
        # Arrange
        get_endpoint.return_value = {'Data': []}

        # Act
        result = FleetUpManager.get_fleetup_timers()

        # Assert
        self.assertDictEqual({}, result)
コード例 #2
0
ファイル: views.py プロジェクト: CreoTEK/allianceauth
def fleetup_view(request):
    logger.debug("fleetup_view called by user %s" % request.user)

    operations_list = FleetUpManager.get_fleetup_operations()
    timers_list = FleetUpManager.get_fleetup_timers()
    now = datetime.datetime.now().strftime('%H:%M:%S')

    context = {"timers_list": sorted(timers_list.items()),
               "operations_list": sorted(operations_list.items()),
               "now": now}

    return render(request, 'registered/fleetup.html', context=context)
コード例 #3
0
ファイル: views.py プロジェクト: dscryhub/allianceauth-1
def fleetup_view(request):
    logger.debug("fleetup_view called by user %s" % request.user)

    operations_list = FleetUpManager.get_fleetup_operations()
    timers_list = FleetUpManager.get_fleetup_timers()
    now = datetime.datetime.now().strftime('%H:%M:%S')

    context = {
        "timers_list": sorted(timers_list.items()),
        "operations_list": sorted(operations_list.items()),
        "now": now
    }

    return render(request, 'registered/fleetup.html', context=context)
コード例 #4
0
def fleetup_view(request):
    logger.debug("fleetup_view called by user %s" % request.user)

    operations_list = FleetUpManager.get_fleetup_operations()
    if operations_list is None:
        messages.add_message(
            request, messages.ERROR,
            _("Failed to get operations list, contact your administrator"))
        operations_list = {}
    timers_list = FleetUpManager.get_fleetup_timers()
    if timers_list is None:
        messages.add_message(
            request, messages.ERROR,
            _("Failed to get timers list, contact your administrator"))
        timers_list = {}
    now = datetime.datetime.now().strftime('%H:%M:%S')

    context = {
        "timers_list": sorted(timers_list.items()),
        "operations_list": sorted(operations_list.items()),
        "now": now
    }

    return render(request, 'fleetup/index.html', context=context)