#365 Fix unit tests
Merged 6 years ago by abompard. Opened 6 years ago by abompard.
abompard/fedora-hubs fix-unit-tests  into  develop

@@ -1,7 +1,6 @@ 

  import React from 'react';

  import PropTypes from 'prop-types';

  import {

-   IntlProvider,

    defineMessages,

    FormattedMessage,

    } from 'react-intl';
@@ -26,15 +25,13 @@ 

          );

      });

      return (

-       <IntlProvider locale={navigator.language}>

-         <div className="component-feed">

-           { (items.length == 0 && this.props.loaded) ?

-             <FormattedMessage {...messages.no_items} tagName="i" />

-             :

-             items

-           }

-         </div>

-       </IntlProvider>

+       <div className="component-feed">

+         { (items.length == 0 && this.props.loaded) ?

+           <FormattedMessage {...messages.no_items} tagName="i" />

+           :

+           items

+         }

+       </div>

      );

    }

  

@@ -1,4 +1,5 @@ 

  import React from 'react';

+ import {IntlProvider} from 'react-intl';

  import ItemsGetter from '../../components/feed/ItemsGetter.jsx';

  import Feed from '../../components/feed/Feed.jsx';

  
@@ -23,19 +24,21 @@ 

  

    render() {

      return (

-       <ItemsGetter

-         url={this.props.url}

-         sse={{

-           eventName: "hubs:widget-updated",

-           shouldReload: (idx) => (parseInt(idx) === this.props.widgetIdx),

-         }}

-         handleData={this.handleServerData}

-         >

-         <Feed

-           items={this.state.items}

-           loaded={this.state.loaded}

-           />

-       </ItemsGetter>

+       <IntlProvider locale={navigator.language}>

+         <ItemsGetter

+           url={this.props.url}

+           sse={{

+             eventName: "hubs:widget-updated",

+             shouldReload: (idx) => (parseInt(idx) === this.props.widgetIdx),

+           }}

+           handleData={this.handleServerData}

+           >

+           <Feed

+             items={this.state.items}

+             loaded={this.state.loaded}

+             />

+         </ItemsGetter>

+       </IntlProvider>

      );

    }

  

@@ -42,7 +42,10 @@ 

      "unmockedModulePathPatterns": [

        "<rootDir>/node_modules/react/",

        "<rootDir>/node_modules/react-dom/",

-       "<rootDir>/node_modules/react-addons-test-utils/"

+       "<rootDir>/node_modules/prop-types/",

+       "<rootDir>/node_modules/react-addons-test-utils/",

+       "<rootDir>/node_modules/react-intl/",

+       "<rootDir>/node_modules/intl-messageformat/"

      ]

    },

    "author": "Eric Barbour <ebarbour@redhat.com>",

@@ -1,13 +1,9 @@ 

  from __future__ import unicode_literals

  

- import six

- from mock import Mock

- 

  from hubs.app import app

  from hubs.tests import APPTest

  from hubs.widgets.base import Widget

- from hubs.widgets.caching import CachedFunction

- from hubs.widgets.view import WidgetView, RootWidgetView

+ from hubs.widgets.view import RootWidgetView

  

  

  class TestingWidget(Widget):

@@ -20,7 +20,7 @@ 

          cache.delete("owned_packages:abompard")

  

      def _is_cached(self):

-         result = cache.get("owned_packages:abompard", ignore_expiration=True)

+         result = cache.get(b"owned_packages:abompard", ignore_expiration=True)

          return not isinstance(result, dogpile.cache.api.NoValue)

  

      def test_get_owned_packages(self):

@@ -18,6 +18,7 @@ 

              'text': 'Testing.',

              'title': "<span class='glyphicon glyphicon-info-sign' "

                       "aria-hidden='true'></span> About",

+             'edit_mode': False,

          })

  

      def test_view_authz(self):

@@ -86,6 +86,7 @@ 

              'location': 'United States',

              'timezone': 'UTC',

              'usergroup': True,

+             'edit_mode': False,

          })

  

      def test_view_authz(self):

@@ -15,15 +15,16 @@ 

          response = self.check_url('/ralph/%i/json' % widget.idx, user)

          data = json.loads(response.get_data(as_text=True))

          self.assertDictEqual(data['data'], {

-             u'fedmsgs': 83854,

-             u'fedmsgs_text': u'83,854',

-             u'subscribers': [],

-             u'subscribed_to': [],

-             u'subscribers_text': u'0',

-             u'subscribed_text': u'0',

-             u'username': u'ralph',

-             u'hub_subscribe_url': u'/api/hub/ralph/subscribe',

-             u'hub_unsubscribe_url': u'/api/hub/ralph/unsubscribe',

+             'fedmsgs': 83854,

+             'fedmsgs_text': '83,854',

+             'subscribers': [],

+             'subscribed_to': [],

+             'subscribers_text': '0',

+             'subscribed_text': '0',

+             'username': 'ralph',

+             'hub_subscribe_url': '/api/hub/ralph/subscribe',

+             'hub_unsubscribe_url': '/api/hub/ralph/unsubscribe',

+             'edit_mode': False,

          })

  

      def test_view_authz(self):

@@ -23,6 +23,7 @@ 

                  "urls": [

                      "<a href=\"ralph/\">ralph/</a>"

                  ],

+                 'edit_mode': False,

              },

              "description": None,

              "hub": "ralph",

@@ -2,7 +2,7 @@ 

  

  from hubs.widgets import validators

  from hubs.widgets.base import Widget

- from hubs.widgets.view import WidgetView, RootWidgetView

+ from hubs.widgets.view import RootWidgetView

  

  

  class About(Widget):

@@ -5,7 +5,7 @@ 

  

  from hubs.widgets import validators

  from hubs.widgets.base import Widget

- from hubs.widgets.view import WidgetView, RootWidgetView

+ from hubs.widgets.view import RootWidgetView

  from hubs.widgets.caching import CachedFunction

  

  

@@ -7,7 +7,7 @@ 

  from hubs.utils.pkgdb import get_owned_packages

  from hubs.widgets import validators

  from hubs.widgets.base import Widget

- from hubs.widgets.view import WidgetView, RootWidgetView

+ from hubs.widgets.view import RootWidgetView

  from hubs.widgets.caching import CachedFunction

  

  

file modified
+4 -2
@@ -147,6 +147,8 @@ 

          """

          Export the edit mode status to the template

          """

-         context = super(RootWidgetView, self).get_extra_context(*args, **kwargs)

-         context["edit_mode"] = flask.request.args.get("editmode", "", type=bool)

+         context = super(RootWidgetView, self).get_extra_context(

+             *args, **kwargs)

+         context["edit_mode"] = flask.request.args.get(

+             "editmode", False, type=bool)

          return context

@@ -5,7 +5,7 @@ 

  from hubs.utils import username2avatar

  from hubs.widgets import validators

  from hubs.widgets.base import Widget

- from hubs.widgets.view import WidgetView, RootWidgetView

+ from hubs.widgets.view import RootWidgetView

  from hubs.widgets.caching import CachedFunction

  

  

@@ -4,7 +4,7 @@ 

  

  from hubs.widgets import validators

  from hubs.widgets.base import Widget

- from hubs.widgets.view import WidgetView, RootWidgetView

+ from hubs.widgets.view import RootWidgetView

  from hubs.widgets.caching import CachedFunction