Added: labs/panopticon/trunk/tests/test_committers.py
URL: 
http://svn.apache.org/viewvc/labs/panopticon/trunk/tests/test_committers.py?rev=1493434&view=auto
==============================================================================
--- labs/panopticon/trunk/tests/test_committers.py (added)
+++ labs/panopticon/trunk/tests/test_committers.py Sun Jun 16 00:21:10 2013
@@ -0,0 +1,47 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+from nose.plugins.attrib import attr
+
+from asf.utils.committers import get_committer
+from asf.utils.test import ensure_credentials_stored
+
+
+@attr('integration')
+@ensure_credentials_stored
+def test_get_committer(username, password):
+    committer = get_committer('adc', username, password)
+
+    assert committer.username == 'adc'
+    assert isinstance(committer.member, bool)
+    assert committer.fullname == 'Alan Cabrera'
+    assert 'incubator' in committer.committees
+    assert 'geronimo' in committer.projects
+    assert 'chukwa' in committer.mentoring
+
+    assert committer is get_committer('adc', username, password)
+
+
+@attr('integration')
+@ensure_credentials_stored
+def test_get_non_existent_committer(username, password):
+    try:
+        get_committer('pookie', username, password)
+        assert False, 'pookie is not a committer, yet...'
+    except KeyError:
+        pass

Added: labs/panopticon/trunk/tests/test_config.py
URL: 
http://svn.apache.org/viewvc/labs/panopticon/trunk/tests/test_config.py?rev=1493434&view=auto
==============================================================================
--- labs/panopticon/trunk/tests/test_config.py (added)
+++ labs/panopticon/trunk/tests/test_config.py Sun Jun 16 00:21:10 2013
@@ -0,0 +1,71 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import ConfigParser
+import contextlib
+import os
+
+from mock import patch
+
+from asf.utils.config import load_config
+from asf.utils.file import temp_directory
+
+
[email protected]
+def mock_tools_config_file():
+    with temp_directory() as tmp_dir:
+        mock_tools_cfg_file = os.path.join(tmp_dir, 'asf-tools.ini')
+
+        with patch('asf.utils.config.TOOLS_CFG_FILE', new=mock_tools_cfg_file):
+            yield mock_tools_cfg_file
+
+
+def test_config_file_creation():
+    with mock_tools_config_file() as mock_tools_cfg_file:
+        assert not os.path.exists(mock_tools_cfg_file)
+
+        with load_config([], {}) as config:
+            pass
+
+        assert os.path.exists(mock_tools_cfg_file)
+
+
+def test_config_section_creation():
+    with mock_tools_config_file() as mock_tools_cfg_file:
+        assert not os.path.exists(mock_tools_cfg_file)
+
+        with load_config(['TEST-SECTION'], {}) as config:
+            pass
+
+        config = ConfigParser.SafeConfigParser()
+        config.read(mock_tools_cfg_file)
+
+        assert len(config.sections()) == 1
+        assert 'TEST-SECTION' in config.sections()
+
+
+def test_config_defaults():
+    with mock_tools_config_file() as mock_tools_cfg_file:
+        assert not os.path.exists(mock_tools_cfg_file)
+
+        with load_config(sections=['TEST-SECTION']) as config:
+            config.set('TEST-SECTION', 'c', 'not_d')
+
+        with load_config(sections=['TEST-SECTION'], defaults={'a': 'b', 'c': 
'd'}) as config:
+            assert config.get('TEST-SECTION', 'a') == 'b'
+            assert config.get('TEST-SECTION', 'c') == 'not_d'

Added: labs/panopticon/trunk/tests/test_emails.py
URL: 
http://svn.apache.org/viewvc/labs/panopticon/trunk/tests/test_emails.py?rev=1493434&view=auto
==============================================================================
--- labs/panopticon/trunk/tests/test_emails.py (added)
+++ labs/panopticon/trunk/tests/test_emails.py Sun Jun 16 00:21:10 2013
@@ -0,0 +1,51 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+from nose.plugins.attrib import attr
+
+from asf.utils.emails import aliases_for, email_from_alias, 
canonical_email_address, is_apache_email_address, get_mail_aliases
+from asf.utils.test import ensure_credentials_stored
+
+
+def test_canonical_email_address():
+    assert '[email protected]' == canonical_email_address('[email protected]')
+
+    try:
+        canonical_email_address('[email protected],[email protected]')
+        assert False, 'malformed email addresses should generate a value error'
+    except ValueError:
+        pass
+
+
+def test_is_apache_email_address():
+    assert is_apache_email_address('[email protected]')
+
+
+@attr('integration')
+@ensure_credentials_stored
+def test_aliases_for(username, password):
+    aliases = aliases_for('[email protected]', get_mail_aliases(username, 
password))
+    assert '[email protected]' in aliases
+    assert '[email protected]' in aliases
+    assert '[email protected]' in aliases
+
+
+@attr('integration')
+@ensure_credentials_stored
+def test_email_from_alias(username, password):
+    assert email_from_alias('[email protected]', get_mail_aliases(username, 
password)) == '[email protected]'

Added: labs/panopticon/trunk/tests/test_podlings.py
URL: 
http://svn.apache.org/viewvc/labs/panopticon/trunk/tests/test_podlings.py?rev=1493434&view=auto
==============================================================================
--- labs/panopticon/trunk/tests/test_podlings.py (added)
+++ labs/panopticon/trunk/tests/test_podlings.py Sun Jun 16 00:21:10 2013
@@ -0,0 +1,58 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import os
+import datetime
+
+from nose.plugins.attrib import attr
+
+from asf.incubator.podlings import Podling, retired, graduated, incubating, 
VALID_STATUS
+from asf.utils.committers import get_committer
+from asf.utils.test import ensure_credentials_stored
+
+
+DATA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data')
+
+
+@attr('integration')
+@ensure_credentials_stored
+def test_from_xml(username, password):
+    with open(os.path.join(DATA_ROOT, 'podlings.xml'), 'r') as fh:
+        podlings = Podling.from_file_handle(fh)
+        assert podlings
+        assert len(podlings) == 184
+
+        for podling in podlings:
+            assert podling.name
+            assert podling.description
+            assert podling.resource
+            assert podling.sponsor
+            assert podling.start_date and isinstance(podling.start_date, 
datetime.date)
+            assert not podling.end_date or isinstance(podling.end_date, 
datetime.date)
+            assert podling.status in VALID_STATUS
+            assert not podling.reporting_group or 
isinstance(podling.reporting_group, int)
+            for mentor in podling.mentors:
+                try:
+                    committer = get_committer(mentor, username, password)
+                    print committer.fullname, 'is a committer'
+                except KeyError:
+                    print mentor, 'is not a committer'
+
+        assert len(incubating(podlings)) == 34
+        assert len(graduated(podlings)) == 118
+        assert len(retired(podlings)) == 32



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to